package top.kaoshanji.p1ch01a;

/**
 * 代码清单-p1ch01a-24页b：参数传递-可变参数
 * author kaoshanji
 * ^_^
 * create time 2025/2/15 16:43
 */
public class VarArg {

    public static void main(String[] args) {
        System.out.println(max(0));
        System.out.println(max(0,2));
        System.out.println(max(0,2,4));
        System.out.println(max(0,2,4,5));
    }

    public static int max(int min, int ... a) {
        int max = min;
        for (int i = 0; i < a.length; i++) {
            if (max < a[i]) {
                max = a[i];
            }
        }

        return max;
    }



}
